package 补充.输入输出操作.文件操作;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class 字节内存操作流 {
    public static void main(String[] args) throws IOException {
        int a = 1;
        int b = 2;
        int c = 3;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        baos.write(a);
        baos.write(b);
        baos.write(c);
        baos.close();
        byte[] ba = baos.toByteArray();
        for (int i = 0; i < ba.length; i++) {
            System.out.print((char) ba[i]);
        }
        System.out.println("*****************************");
        ByteArrayInputStream bais = new ByteArrayInputStream(ba);
        while ((b=bais.read()) != -1) {
            System.out.print(b);
        }
        bais.close();
    }
}
